//
//  ViewController.m
//  YYCache的简单使用
//
//  Created by chenleping on 2018/6/20.
//  Copyright © 2018年 IAPTest. All rights reserved.
//

#import "ViewController.h"

#import <YYCache.h>
#import "Person.h"


#define CacheName @"cacheName"
#define Key @"key"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.view.backgroundColor = [UIColor yellowColor];
    
    NSString * value = @"存储的数据...";
    NSString * key = Key;
    YYCache * yyCache = [YYCache cacheWithName:CacheName];
    
    [yyCache setObject:value forKey:key];
    Person * ls = [[Person alloc] init];
    ls.name = @"ls";
    [yyCache setObject:ls forKey:@"ls"];
    Person * ls1 = [yyCache objectForKey:@"ls"];
    NSLog(@"name:===%@", ls1.name);
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    YYCache * yyCache = [YYCache cacheWithName:CacheName];
    [yyCache removeAllObjects]; // 移除所有缓存
    BOOL isContains = [yyCache containsObjectForKey:Key];
    NSLog(@"isContains:===%d", isContains);
    id value = [yyCache objectForKey:Key];
    NSLog(@"value:===%@", value);
}




@end
